from flask import Blueprint, render_template
from app.models import Post, Category
from app.utils.helpers import process_straight_content

main_bp = Blueprint('main', __name__)

@main_bp.route('/')
def index():
    posts = Post.query.order_by(Post.timestamp.desc()).limit(5).all()
    categories = Category.query.all()
    for post in posts:
        post.formatted_content = process_straight_content(post.content)
        
    return render_template('index.html', posts=posts, categories=categories)

@main_bp.route('/about')
def about():
    return render_template('about.html')

